/**
 * 
 */
package com.lanswon.qzsmk.service.preService;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.model.BikeSection;
import com.lanswon.qzsmk.vo.BikeConsumeRecord;
import com.lanswon.qzsmk.vo.VoucherVo;

/**
 *  对接自行车接口
 * @author sun
 *
 */
public interface BikeService{
	
	/**
	 * 查询自行车消费记录
	 * @param citizenCardNo
	 * @param startdate
	 * @param enddate
	 * @return
	 * @throws ApplicationException 
	 */
	List<BikeConsumeRecord> bikeAppqueryConsumeRecord(String citizenCardNo,String startdate,String enddate) throws ApplicationException;
	
	/**
	 * 卡片故障时，重写卡
	 * @param cardsn
	 * @param citizenCardNo
	 * @throws ApplicationException
	 */
	JSONArray bikeAppRewriteCardData(String cardsn, String citizenCardNo)throws ApplicationException;
	
	/**
	 * 挂失、解绑
	 * @param citizenCardNo
	 * @param status
	 * @throws ApplicationException
	 */
	void bikeAppLossAndUnbind(String citizenCardNo,String status)throws ApplicationException;
	
	/**
	 * 充值撤销
	 * @param citizenCardNo
	 * @param cardsn
	 * @param revokeMoney
	 */
	void bikeAppRechargeRevoke(String citizenCardNo)throws ApplicationException;
	
	/**
	 * 自行车应用充值
	 * @throws ApplicationException
	 */
	VoucherVo bikeAppRecharge(String citizenCardNo,String recharge,String vipno,String vipcardsn,String balance) throws ApplicationException ;
	
	/**
	 * 开通自行车应用
	 * @param citizenCardNo 市民卡号
	 * @param cardsn 卡片4字节唯一号
	 * @param recharge 充值金额
	 * @return
	 * @throws ApplicationException
	 */
	Map<String,Object> openBikeApp(String citizenCardNo,String cardsn) throws ApplicationException;
	
	/**
	 * 关闭自行车应用
	 */
	VoucherVo closeBikeApp(String citizenCardNo) throws ApplicationException;
	
	/**
	 * 补换卡
	 * @return
	 */
	Map<String,Object> SupplementAndChangeCard(String oldCitizenCardNo,String newCitizenCardNo,String newCardsn)throws ApplicationException ;
	
	/**
	 * 开通应用写卡成功后调用
	 */
	VoucherVo writeCardSuccess(String citizenCardNo,String cardsn,String recharge,String vipno,String vipcardsn)throws ApplicationException;;

	/**
	 * 获取密钥
	 * @param cardsn
	 * @return
	 */
	List<BikeSection> queryBikeSection(String citizenCardNo,String cardsn) throws ApplicationException;

	//=========以上是关联核心系统业务===========分割线========以下是封装调用的自行车接口===========
	//=========以上是关联核心系统业务===========分割线========以下是封装调用的自行车接口===========
	//=========以上是关联核心系统业务===========分割线========以下是封装调用的自行车接口===========
	
	/**
	 * 查询自行车用户信息
	 * @param  01  按照市民卡号查询    
	 * @return
	 */
	JSONObject queryBikeUserByCitizenCardNo(String citizenCardNo)throws ApplicationException ;
	
	/**
	 * 查询自行车用户信息
	 * @param    02按照会员号查询   
	 * @return
	 */
	JSONObject queryBikeUserByVipNo(String vipno)throws ApplicationException ;
	
	/**
	 * 查询自行车用户信息
	 * @param    03 按照证件查询
	 * @return
	 */
	JSONObject queryBikeUserByIdNo(String idtype, String idNo)throws ApplicationException ;

	/**
	 * 请求查询
	 * @param   
	 * @return
	 */
	JSONObject doPostBike(List<NameValuePair> parameForToken,String url) throws ApplicationException ;
	
	/**
	 * 写卡数据
	 * @param cardsn
	 * @param cardtype
	 * @param cardfaceno
	 * @param idtype
	 * @param idno
	 * @param birthday
	 * @return
	 * @throws ApplicationException
	 */
	JSONObject writeData(String cardsn,String cardtype,String cardfaceno,String idtype,String idno,String birthday) throws ApplicationException ;

	/**
	 * 注册会员
	 * @param cardsn
	 * @param citizenCardNo
	 * @param vipno
	 * @param vipcardsn
	 * @param vipname
	 * @param sex
	 * @param idtype
	 * @param idno
	 * @param birthday
	 * @param recharge
	 * @param deposit
	 * @param address
	 * @param mobilephone
	 * @param linkman
	 * @param linkphone
	 * @return
	 * @throws ApplicationException
	 */
	JSONObject regMemberInfo(String cardsn,String citizenCardNo,String vipno,String vipcardsn,String vipname,String sex,String idtype,String idno,String birthday,String recharge,BigDecimal deposit,String address,String mobilephone,String linkman,String linkphone)throws ApplicationException;

	/**
	 * 请求最后一次借还状态
	 * @param vipno
	 * @param vipcardsn
	 * @return
	 */
	JSONObject memberBorrowOrBackLastTime(String vipno,String vipcardsn)throws ApplicationException;

	/**
	 *补换卡申请写卡数据
	 * @param oldvipno
	 * @param cardsn
	 * @param newCitizenCardNo
	 * @return
	 */
	JSONObject memberExchangeNewCard(String oldvipno,String newCardsn,String newCitizenCardNo)throws ApplicationException;

	/**
	 * 补换卡写卡成功后调用,核心系统处理补换卡业务调用
	 * @param newcardsn
	 * @param newcitizenCardNo
	 * @param oldvipno
	 * @param oldvipcardsn
	 * @param newvipno
	 * @param newvipcardsn
	 */
	JSONObject successExchangeNewCard(String newCardsn,String newCitizenCardNo,String oldVipno,String oldVipcardsn,String newVipno,String newVipcardsn)throws ApplicationException;


	/**
	 * 请求充值
	 * @param vipno
	 * @param vipcardsn
	 * @param recharge
	 * @return
	 */
	JSONObject memberCardRecharge(String vipno,String vipcardsn,String recharge,String tradenumber)throws ApplicationException;

	/**
	 * 充值冲正
	 * @param vipno
	 * @param vipcardsn
	 * @param tradenumber
	 * @return
	 * @throws ApplicationException
	 */
	JSONObject rechargeReverse(String vipno,String vipcardsn,String tradenumber)throws ApplicationException;

	/**
	 * 修改会员信息
	 * @param vipno
	 * @param vipcardsn
	 * @param vipname
	 * @param sex
	 * @param idtype
	 * @param idno
	 * @param birthday
	 * @param address
	 * @param mobilephone
	 * @param linkman
	 * @param linkphone
	 * @return
	 */
	JSONObject updateMemberInfo(String vipno,String vipcardsn,String vipname,String sex,String idtype,String idno,String birthday,String address,String mobilephone,String linkman,String linkphone)throws ApplicationException;
	
	/**
	 * 请求挂失/解挂
	 * @param vipno
	 * @param newstate 00：解挂   01：挂失
	 * @return
	 */
	JSONObject cardReportLossOrRelease(String vipno,String newstate)throws ApplicationException;
	
	/**
	 * 重写卡数据
	 * @param cardsn
	 * @param citizenCardNo
	 * @param vipno
	 * @param vipcardsn
	 * @return
	 */
	JSONObject rewriteMemberCardData(String cardsn,String citizenCardNo,String vipno,String vipcardsn)throws ApplicationException;
	
	/**
	 * 请求退卡
	 * @param vipno
	 * @return
	 * @throws ApplicationException
	 */
	JSONObject backCard(String vipno)throws ApplicationException;
	
	/**
	 * 查询自行车用车、消费记录
	 * @param vipno
	 * @param vipcardsn
	 * @param startdate 结束日期和开始日期之间最多相隔30天。
	 * @param enddate 结束日期和开始日期之间最多相隔30天。
	 * @param reqtype “00”表示查询用车记录(包含产生费用的记录)；“01”仅仅查询产生消费的记录
	 * @param sn 首次请求填1表示从第1条记录开始，之后根据返回的sn顺序号请求
	 * @return
	 * @throws ApplicationException
	 */
	 List<BikeConsumeRecord> consumeRecord(String vipno,String vipcardsn,String startdate,String enddate,String reqtype,String sn, List<BikeConsumeRecord> list)throws ApplicationException;
}
